//
//  UTSUNUserNotificationCenterDelegate.swift
//  WRSVoipProject
//
//  Created by Admin on 2024/9/10.
//

import UIKit

public class UTSUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
    public var willPresentCallback: ((_ center: UNUserNotificationCenter, _ notification: UNNotification, _ completionHandler:  (UNNotificationPresentationOptions) -> Void) -> Void)?
    
    public  var didReceiveCallback: ((_ center: UNUserNotificationCenter, _ response: UNNotificationResponse, _ completionHandler:  () -> Void) -> Void)?
    
    // MARK: - UNUserNotificationCenterDelegate
    public  func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        self.willPresentCallback?(center, notification, completionHandler)
         // 调用completionHandler将展示通知
//        var array: UNNotificationPresentationOptions = UNNotificationPresentationOptions()
//        array.insert(.alert)
//        completionHandler(array)
//        print("willPresent")
    }
    
    public  func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        self.didReceiveCallback?(center, response, completionHandler)
//        completionHandler()
//        // 点击了通知
//        print("didReceive")
//        self.descLbl.text = "didReceive"
    }
}
